package com.bestcem.xm.wallet.util;

import com.bestcem.xm.wallet.util.business.MailUtil;
import lombok.extern.slf4j.Slf4j;
import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Component;

import javax.annotation.Resource;

/**
 * 钱包异步方法工具类
 *
 * @author panyun <yun.pan@idiaoyan.com>
 * @version v1.0
 * @date 2022/9/5 18:22
 */
@Slf4j
@Component
public class WalletAsyncUtil {

    @Resource
    private MailUtil mailUtil;

    @Async("user_email_executor")
    public void sendMailAsync(String[] to, String subject, String content) {
        boolean sendEmail = mailUtil.sendEmail(to, subject, content);
        if (!sendEmail) {
            log.error("[Wallet] Async sendEmail to {} Error; subject {} , content {}", to, subject, content);
        }
    }

}
